package org.kl.bf.entity.basic;

import java.sql.Date;
import java.util.Set;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

import org.kl.bf.entity.AuditableEntity;
import org.kl.bf.entity.Excel;
import org.kl.bf.utils.BasicConstants;

import com.fasterxml.jackson.annotation.JsonFormat;

@Entity
@Table(name = "basic_staffinfo")
public class Staffinfo extends AuditableEntity {
	private static final long serialVersionUID = 1L;
	@Excel(exportName = "员工姓名")
	private String staffName; // 员工姓名
	@Excel(exportName = "是否为主岗位负责人")
	private Integer isPostLeader; // 是否为主岗位负责人
	@Excel(exportName = "身份证号码")
	private String identityCardNo;// 身份证号码
	@Excel(exportName = "性别")
	private String sex; // 性别
	@Excel(exportName = "出生年月")
	private Date birthday; // 出生年月
	@Excel(exportName = "民族")
	private String nation; // 民族
	@Excel(exportName = "政治面貌")
	private String politicalLandscape;// 政治面貌
	@Excel(exportName = "工号")
	private String jobNumber; // 工号
	@Excel(exportName = "工作电话")
	private String workPhone; // 工作电话
	@Excel(exportName = "电话号码")
	private String phoneNumber;// 电话号码
	@Excel(exportName = "短号")
	private String shortNumber;// 短号
	@Excel(exportName = "电子邮箱")
	private String email; // 电子邮箱
	@Excel(exportName = "家庭住址")
	private String homeAddress; // 家庭住址
	@Excel(exportName = "银行账号")
	private String bankAccount; // 银行账号
	@Excel(exportName = "开户银行")
	private String bankName; // 开户银行
	@Excel(exportName = "学历")
	private String educational; // 学历
	@Excel(exportName = "最后毕业学校")
	private String schools; // 最后毕业学校
	@Excel(exportName = "专业")
	private String specialty;// 专业
	@Excel(exportName = "毕业时间")
	private Date graduateDate;// 毕业时间
	@Excel(exportName = "是否启用", exportConvertSign = 1)
	private Integer enable = BasicConstants.NO_INT; // 是否启用
	@Excel(exportName = "主岗位", exportProperty = "postName")
	private Post post; // 主岗位
	@Excel(exportName = "所属组织", exportProperty = "orgName")
	private Organization organization; // 所属组织
	private Set<Post> postSet;

	public Staffinfo() {
	}

	public Staffinfo(String id) {
		this.id = id;
	}

	@ManyToMany
	@JoinTable(name = "basic_staff_post", schema = "", joinColumns = { @JoinColumn(name = "staff_id", nullable = false, updatable = false) }, inverseJoinColumns = { @JoinColumn(name = "post_id", nullable = false, updatable = false) })
	public Set<Post> getPostSet() {
		return postSet;
	}

	public void setPostSet(Set<Post> postSet) {
		this.postSet = postSet;
	}

	@ManyToOne
	@JoinColumn(name = "org_id")
	public Organization getOrganization() {
		return organization;
	}

	public void setOrganization(Organization organization) {
		this.organization = organization;
	}

	@ManyToOne
	@JoinColumn(name = "major_post_id")
	public Post getPost() {
		return post;
	}

	public void setPost(Post post) {
		this.post = post;
	}

	public String getStaffName() {
		return staffName;
	}

	public void setStaffName(String staffName) {
		this.staffName = staffName;
	}

	public Integer getIsPostLeader() {
		return isPostLeader;
	}

	public void setIsPostLeader(Integer isPostLeader) {
		this.isPostLeader = isPostLeader;
	}

	public String getIdentityCardNo() {
		return identityCardNo;
	}

	public void setIdentityCardNo(String identityCardNo) {
		this.identityCardNo = identityCardNo;
	}

	public String getSex() {
		return sex;
	}

	public void setSex(String sex) {
		this.sex = sex;
	}

	// 设定JSON序列化时的日期格式
	@Column(name = "birthday")
	@JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+08:00")
	public Date getBirthday() {
		return birthday;
	}

	public void setBirthday(Date birthday) {
		this.birthday = birthday;
	}

	public String getNation() {
		return nation;
	}

	public void setNation(String nation) {
		this.nation = nation;
	}

	public String getPoliticalLandscape() {
		return politicalLandscape;
	}

	public void setPoliticalLandscape(String politicalLandscape) {
		this.politicalLandscape = politicalLandscape;
	}

	public String getJobNumber() {
		return jobNumber;
	}

	public void setJobNumber(String jobNumber) {
		this.jobNumber = jobNumber;
	}

	public String getWorkPhone() {
		return workPhone;
	}

	public void setWorkPhone(String workPhone) {
		this.workPhone = workPhone;
	}

	public String getPhoneNumber() {
		return phoneNumber;
	}

	public void setPhoneNumber(String phoneNumber) {
		this.phoneNumber = phoneNumber;
	}

	public String getShortNumber() {
		return shortNumber;
	}

	public void setShortNumber(String shortNumber) {
		this.shortNumber = shortNumber;
	}

	public String getEmail() {
		return email;
	}

	public void setEmail(String email) {
		this.email = email;
	}

	public String getHomeAddress() {
		return homeAddress;
	}

	public void setHomeAddress(String homeAddress) {
		this.homeAddress = homeAddress;
	}

	public String getBankAccount() {
		return bankAccount;
	}

	public void setBankAccount(String bankAccount) {
		this.bankAccount = bankAccount;
	}

	public String getBankName() {
		return bankName;
	}

	public void setBankName(String bankName) {
		this.bankName = bankName;
	}

	public String getEducational() {
		return educational;
	}

	public void setEducational(String educational) {
		this.educational = educational;
	}

	public String getSchools() {
		return schools;
	}

	public void setSchools(String schools) {
		this.schools = schools;
	}

	public String getSpecialty() {
		return specialty;
	}

	public void setSpecialty(String specialty) {
		this.specialty = specialty;
	}

	public Date getGraduateDate() {
		return graduateDate;
	}

	// 设定JSON序列化时的日期格式
	@Column(name = "graduate_date")
	@JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+08:00")
	public void setGraduateDate(Date graduateDate) {
		this.graduateDate = graduateDate;
	}

	public Integer getEnable() {
		return enable;
	}

	public void setEnable(Integer enable) {
		this.enable = enable;
	}

	/*
	 * public String isPostLeaderConvert() { return isPostLeader == 1 ? "是" :
	 * "否"; }
	 */
	public String enableConvert() {
		return enable == 1 ? "是" : "否";

	}

}
